#include <stdio.h>
#include <stdlib.h>

typedef struct SList
{
  struct SList* next;
  int data;
}SList;

void SListPush(SList** pplist,int x)
{
  SList* newnode=(SList*)malloc(sizeof(SList));
  if(newnode==NULL)
  {
    printf("malloc fail!");
    exit(-1);
  }
  newnode->next=NULL;
  newnode->data=x;

  if((*pplist)==NULL)
  {
    (*pplist)=newnode;
  }
  else
  {
    (*pplist)->next=newnode;
  }

}

void SwapFront(SList** pplist)
{
  SList* cur=(*pplist)->next;
  (*pplist)->next=(*pplist)->next->next;
  cur->next=(*pplist);
}

void SwapTail(SList** pplist)
{
  SList* cur=(*pplist);
  while(cur->next->next->next!=NULL)
  {
    cur=cur->next;
  }
  SList* tail=(*pplist);
  while(tail->next!=NULL)
  {
    tail=tail->next;
  }
  tail->next=cur->next;
  cur->next->next=NULL;
  cur->next=tail;
}

void PrintSList(SList* plist)
{
  SList* cur=plist;
  while(cur!=NULL)
  {
    printf("%d",cur->data);
    cur=cur->next;
  }

}

int main()
{
  int n=0;
  scanf("%d",&n);
  int array[100]={0};
  int i=0;
  for(i=0;i<n;i++)
  {
    scanf("%d",&array[i]);
  }

  SList* phead=NULL;

  for(i=0;i<n;i++)
  {
    SListPush(&phead,array[i]);
  }

  SwapFront(&phead);

  SwapTail(&phead);

  PrintSList(phead);
  return 0;
}
